//
//  ViewController.swift
//  TarBarJump
//
//  Created by 郑东喜 on 2016/12/12.
//  Copyright © 2016年 郑东喜. All rights reserved.
//

import UIKit

class ViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        view.backgroundColor = UIColor.white
        
        let serviceVC = Nav.init(rootViewController: ViewController2())
        let commuVC = Nav.init(rootViewController: ViewController3())
        
        
        self.setupChildVC(serviceVC, title: "服务区", imageName: "nav_2", selectImageName: "nav_2_on")
        
        self.setupChildVC(commuVC, title: "首页", imageName: "nav_1", selectImageName: "nav_1_on")

    }
    
    //添加子页面
    func setupChildVC(_ childVC: UIViewController,title: String,imageName: String,selectImageName: String){
        
        childVC.title = title
        childVC.tabBarItem.image = UIImage.init(named: imageName)
        //        不在渲染图片
        childVC.tabBarItem.selectedImage = UIImage.init(named: selectImageName)?.withRenderingMode(.alwaysOriginal)
        
        self.addChildViewController(childVC)
        
        
    }

}

